<?php

declare(strict_types=1);

namespace App\Command;

use App\Model\MyObject;
use App\Service\CosService;
use Hyperf\Command\Command as HyperfCommand;
use Hyperf\Command\Annotation\Command;
use Hyperf\Guzzle\ClientFactory;
use Hyperf\Utils\Str;
use Psr\Container\ContainerInterface;

/**
 * @Command
 */
#[Command]
class DevCommand extends HyperfCommand
{
    /**
     * @var ContainerInterface
     */
    protected $container;

    public function __construct(ContainerInterface $container)
    {
        $this->container = $container;

        parent::__construct('dev:run');
    }

    public function configure()
    {
        parent::configure();
        $this->setDescription('Hyperf Demo Command');
    }

    public function handle()
    {
        // for ($i = 0; $i < 100; $i++) {
        //     MyObject::query()->create([
        //         'name' => Str::random(8),
        //         'url' => 'https://srat.sy1011one.xyz/test/pet/B85A31EB64F482EF44CBDEB6FF49C1C5.jpg',
        //         'address' => Str::random(6),
        //         'brief' => Str::random(7),
        //     ]);
        // }
        // $client = $this->container->get(ClientFactory::class)->create();
        // $res = $client->get('http://129.204.67.56:9801/fetch_objects');
        // var_dump($res->getBody()->getContents());
        function sm3HMAC($key, $data) {
            return hash_hmac('sm3', $data, $key);
        }
    }
}
